<?php
include_once('../model/DealerDAO.php');

$result = "false";

if(isset($_POST['emailre'])) {
	$email = $_POST['emailre'];
	if(checkEmailRegis($email) == false) {
		if(isset($_POST['passre']) && isset($_POST['namere']) && isset($_POST['gend']) && isset($_POST['birthdayre']) && isset($_POST['phonere']) && isset($_POST['homephonere']) && isset($_POST['addressre']) && isset($_POST['provicere']) && isset($_POST['dvct']) && isset($_POST['dcct']) && isset($_POST['gtcv']) && isset($_POST['gtknlv']) && isset($_POST['stk']) && isset($_POST['ngh'])) {
			$pass = md5($_POST['passre']);
			$name = $_POST['namere'];
			$gender = $_POST['gend'];
			$dayofbirth = strtotime($_POST['birthdayre']);
			$mobile = $_POST['phonere'];
			$homephone = $_POST['homephonere'];
			$address = $_POST['addressre'];
			$province = $_POST['provicere'];
			$dvct = $_POST['dvct'];
			$dcct = $_POST['dcct'];
			$gtcv = $_POST['gtcv'];
			$gtknlv = $_POST['gtknlv'];
			$codebank = $_POST['stk'];
			$bank = $_POST['ngh'];
			$datecreate = time();
			
			if(insertDealer($email, $pass, $name, $gender, $dayofbirth, $mobile, $homephone, $address, $province, $dvct, $dcct, $gtcv, $gtknlv, $codebank, $bank, $datecreate)) {
				$result = "true";
			}
		}
	} else {
		$result = "exits";
	}
}

echo json_encode($result);
?>